typedef struct {
    int *data;
    int top;
} MinStack;


MinStack* minStackCreate() {
      MinStack* obj=(MinStack*)malloc(sizeof(MinStack));
      obj->data=malloc(sizeof(int)*1000);
      obj->top=-1;
      return obj;
}

void minStackPush(MinStack* obj, int val) {
     if(obj->top==999) return;
     obj->top++;
     obj->data[obj->top]=val;
}

void minStackPop(MinStack* obj) {
    if(obj->top<=-1) return;
    obj->top--;
}

int minStackTop(MinStack* obj) {
    if(obj->top<=-1) return;
    return obj->data[obj->top];
}

int minStackGetMin(MinStack* obj) {
    if(obj->top<=-1) return;
    int t=obj->data[0];
    for(int i=0;i<=obj->top;i++){
      if(obj->data[i]<t){
        t=obj->data[i];
      }
    }
    return t;
}

void minStackFree(MinStack* obj) {
      free(obj->data);
      obj->data=0;
      free(obj);
      obj=NULL;
}
